package next.fire.spinus.logx.api.query;

import java.util.Calendar;
import java.util.Date;

/**
 * Created by daibing on 2020/6/5.
 */
public class DateRange {

    private Date startTime;

    private Date endTime;

    public DateRange() {
    }

    public DateRange(Date startTime, Date endTime) {
        this.startTime = startTime;
        this.endTime = endTime;
    }

    public DateRange(Date time, int rangeMinutes, boolean reverse) {
        Calendar ca = Calendar.getInstance();
        ca.setTime(time);
        ca.add(Calendar.MINUTE, reverse ? -rangeMinutes : rangeMinutes);
        this.startTime = reverse ? ca.getTime() : time;
        this.endTime = reverse ? time : ca.getTime();
    }

    public Date getStartTime() {
        return startTime;
    }

    public void setStartTime(Date startTime) {
        this.startTime = startTime;
    }

    public Date getEndTime() {
        return endTime;
    }

    public void setEndTime(Date endTime) {
        this.endTime = endTime;
    }

}
